package com.acwing.chapter2;

import java.io.*;

/**
 * @author anan
 * @create 2021-07-26 20:59
 */
public class Chafenjuzhen {
    public static int N = 1010;
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] str1 = reader.readLine().split(" ");
        int n = Integer.parseInt(str1[0]);
        int m = Integer.parseInt(str1[1]);
        int q = Integer.parseInt(str1[2]);

        int[][] a = new int[N][N];
        int[][] b = new int[N][N];
        int x1, y1, x2, y2, c;
        for (int i = 1; i < n + 1; i++) {
            String[] str2 = reader.readLine().split(" ");
            for (int j = 1; j < m + 1; j++) {
                a[i][j] = Integer.parseInt(str2[j - 1]);
            }
        }
        for (int i = 1; i < n + 1; i++) {
            for (int j = 1; j < m + 1; j++) {
                b[i][j] = a[i][j] - a[i - 1][j] - a[i][j - 1] + a[i - 1][j -1 ];
            }
        }

        while (q-- > 0){
            String[] str3 = reader.readLine().split(" ");
            x1 = Integer.parseInt(str3[0]);
            y1 = Integer.parseInt(str3[1]);
            x2 = Integer.parseInt(str3[2]);
            y2 = Integer.parseInt(str3[3]);
            c = Integer.parseInt(str3[4]);

            b[x1][y1] += c;
            b[x1][y2 + 1] -= c;
            b[x2 + 1][y1] -= c;
            b[x2 + 1][y2 + 1] += c;
        }

        for (int i = 1; i < n + 1 ; i++) {
            for (int j = 1; j < m + 1; j++) {
                b[i][j] += b[i-1][j] + b[i][j - 1] - b[i-1][j-1];
                writer.write(b[i][j] + " ");
            }
            writer.write('\n');
        }
        writer.flush();
        writer.close();
        reader.close();



    }
}
